package com.service;
import com.alibaba.fastjson.JSON;
import com.dao.HatCityDao;
import com.entity.HatCity;
import com.entity.HatProvince;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class HatCityService
{
    @Resource
    private HatCityDao hatCityDao;

    //根据provinceId返回指定城市的json格式字符串
    public String returnCityComboBoxJsonStr( Integer provinceId )
    {
        ArrayList<HatCity> cityList = hatCityDao.getCityByProvinceId( provinceId );
        String jsonStr = JSON.toJSONString( cityList );
        System.out.println( jsonStr );

        return jsonStr;
    }

    //根据id查询城市名
    public String returnCityNameById( Integer id )
    {
        HatCity hatCity = hatCityDao.getCityById( id );

        return hatCity.getCity();
    }
}
